<!--
 * @Author: 码上talk|RC
 * @Date: 2021-07-03 15:34:12
 * @LastEditTime: 2021-08-28 17:14:01
 * @LastEditors: 码上talk|RC
 * @Description: 
 * @FilePath: /ma-portal/components/form/index.vue
 * @微信:  13680065830
 * @邮箱:  3189482282@qq.com
 * @oops: Just do what I think it is right
-->
<template>
  <view :class="classes">
    <slot></slot>
  </view>
</template>

<script>
  import Schema from 'async-validator'
  export default {
    name: 'AxqForm',
    components: {},
    mixins: [],
    props: {
      inline: Boolean,
      labelWidth: String,
      labelAlign: String,
      model: Object,
      rules: Object,
      styleType: String
    },
    data() {
      return {
        validator: null
      }
    },
    provide() {
      return {
        axqForm: this
      }
    },
    computed: {
      classes() {
        let str = 'axq-form'
        if (this.inline) {
          str += ' axq-form--inline'
        }
        return str
      }
    },
    created() {
      let descriptor = this.rules || {}
      this.validator = new Schema(descriptor)
    },
    methods: {
      validate() {
        this.validator.validate(this.model, (errors, fields) => {
          console.log(errors, fields);
        }).catch(e => {
          console.log(e);
        })
      }
    }
  }
</script>

<style lang="less">
  .axq-form {}
</style>